package main
import  (
    "fmt"
)
const(
    WHITE= iota
    BLACK
    BLUE
    RED
    YELLOW
)

type Color byte

type Box struct {
    width,height,depth float64
    color Color
}

type BoxList []Box

func (b Box) volume() float64{
    return b.width*b.height*b.depth;
}

func (b *Box) setColor(c Color){
    b.color = c
}

func (b1 BoxList) BiggestColor() Color{
    v:= 0.00
    k:= Color(WHITE)
    for _,b := range b1{
        if bv:=b.volume();bv >v{
            v = bv
            k =b.color
        }
    }
    return k
}

func (bl BoxList) PrintBlack(){
    for i,_:=range bl {
        bl[i].setColor(BLACK)
    }
}

func (c Color) String() string{
    strings := []string{"WHITE","BLACK","BLUE","RED","YELLOW"}
    return strings[c]
}

func main() {
    boxs:=BoxList{
        Box{4,4,4,RED},
        Box{10,10,2,YELLOW},
        Box{1,1,20,BLACK},
        Box{10,10,1,BLUE},
        Box{10,30,1,WHITE},
        Box{20,20,20,YELLOW},
    }
    fmt.Printf("We have %d boxes in our set \n",len(boxs))
    fmt.Printf("The volume of the first one is %f \n",boxs[0].volume())
    fmt.Println("The last one is",boxs[len(boxs)-1].color.String())
    fmt.Println("The biggest volume box's color is ",boxs.BiggestColor().String())
    fmt.Println("Set Boxlist to black")
    boxs.PrintBlack()
    fmt.Println("The third one color is ",boxs[2].color)
    fmt.Println("Now biggest box's color is ",boxs.BiggestColor().String())
}
